Limit the number of opened transactions per connection to 5.
authorvhanquez@gwig.uk.xensource.com <vhanquez@gwig.uk.xensource.com>
Sat, 29 Jul 2006 13:05:59 +0000 (14:05 +0100)
committervhanquez@gwig.uk.xensource.com <vhanquez@gwig.uk.xensource.com>
Sat, 29 Jul 2006 13:05:59 +0000 (14:05 +0100)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
tools/xenstore/xenstored_transaction.c

index f9d844e045e87acb14160fe3020be7ca8e53fc78..a3f215725617efb3cc31b156bc936bc06ac28d94 100644 (file)
@@ -125,6 +125,7 @@ void do_transaction_start(struct connection *conn, struct buffered_data *in)
 {
        struct transaction *trans, *exists;
        char id_str[20];
+       int started;
 
        /* We don't support nested transactions. */
        if (conn->transaction) {
@@ -132,6 +133,15 @@ void do_transaction_start(struct connection *conn, struct buffered_data *in)
                return;
        }
 
+       started = 0;
+       list_for_each_entry(trans, &conn->transaction_list, list)
+               started++;
+
+       if (started > 5) {
+               send_error(conn, ENOSPC);
+               return;
+       }
+
        /* Attach transaction to input for autofree until it's complete */
        trans = talloc(in, struct transaction);
        INIT_LIST_HEAD(&trans->changes);